# Contributor: rubicon <rubicon@mailo.com>
# Maintainer:
pkgname=ocaml-erm_xmpp
_pkgname=xmpp
pkgver=0_git20220404
_commit=e54d54e142ac9770c37e144693473692bf473530
pkgrel=0
pkgdesc="XMPP protocol implementation for OCaml"
url="https://github.com/hannesm/xmpp"
# riscv64: restricted by ocaml aport
# ppc64le: ocamlbuild terminated with error code 10
arch="all !riscv64 !ppc64le"
license="BSD-3-Clause"
depends="
	ocaml-runtime
	ocaml-base64
	ocaml-erm_xml
	ocaml-mirage-crypto
	"
depends_dev="
	$pkgname=$pkgver-r$pkgrel
	ocaml-base64-dev
	ocaml-erm_xml-dev
	ocaml-mirage-crypto-dev
	"
makedepends="
	$depends_dev
	ocaml
	ocamlbuild
	ocaml-findlib
	ocaml-compiler-libs
	ocaml-camlp4-dev
	"
subpackages="$pkgname-dev"
source="$pkgname-$pkgver.tar.gz::https://github.com/hannesm/xmpp/archive/$_commit/xmpp-$_commit.tar.gz"
builddir="$srcdir/$_pkgname-$_commit"
_ocamldir=usr/lib/ocaml

# 32-bit archs
case "$CARCH" in
	arm*|x86) options="$options textrels" ;;
esac

build() {
	ocaml setup.ml -configure --prefix /usr
	ocaml setup.ml -build
}

check() {
	ocaml setup.ml -test
}

package() {
	export OCAMLFIND_DESTDIR="$pkgdir/$_ocamldir"
	export OCAMLFIND_LDCONF=ignore
	mkdir -vp "$OCAMLFIND_DESTDIR"

	ocaml setup.ml -install
}

dev() {
	default_dev

	cd "$pkgdir"

	local path; for path in $(find $_ocamldir \( \
			-name '*.cmt' -o \
			-name '*.cmti' -o \
			-name '*.cmx' -o \
			-name '*.cmxa' -o \
			-name '*.ml' -o \
			-name '*.mli' \
		\))
	do
		amove "$path"
	done
}

sha512sums="
84e5b165d0257cfbbc83e888adeca2233cca201f66b7ac4d661a1fee56290816d3c36f8793bfae8ca10e52acd76baa4b29ca45e29da2701976d0b676a600252a  ocaml-erm_xmpp-0_git20220404.tar.gz
"
